﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Manager;
using Model;
namespace HealthSystem
{
    public partial class ResultDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindGrid();
            }
        }
        public void BindGrid()
        {
            string tjnd = Request["tjnd"] as string;
            string studentid = Request["studentid"] as string;
            ResultManager manager = new ResultManager();
            HW_Result2013 result = manager.GetModelStudent(tjnd, studentid);
            if (result == null)
            {
                ExtAspNet.Alert.Show("不存在体检记录");
                return;
            }
            //字典翻译
            result = manager.Translate(result);
            //沙眼与视力翻译
            result = manager.GetResult(result);
            this.litXh.Text = result.XH;
            this.litXm.Text = result.XM;
            this.litSex.Text = result.XB;

            this.litMz.Text = result.MZ;


            //str3 = reader2["schoolbh"] as string;
            this.litCsrq.Text = result.CSRQ.ToShortDateString();

            this.litSchoolname.Text = result.SCHOOL_NAME;

            this.litClassname.Text = result.CLASS_NAME;

            this.litRxsj.Text = result.RXSJ;

            //if (!Convert.IsDBNull(reader2["Sg"]))
            //{
            this.litSg.Text = result.SG.HasValue ? Math.Round(result.SG.Value, 1).ToString() + "cm" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Tz"]))
            //{
            this.litTz.Text = result.TZ.HasValue ? Math.Round(result.TZ.Value, 1).ToString() + "kg" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Xw"]))
            //{
            this.litXw.Text = result.XW.HasValue ? Math.Round(result.XW.Value, 1).ToString() + "cm" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Fhl"]))
            //{
            this.litFhl.Text = result.FHL.HasValue ? Math.Round(result.FHL.Value, 1).ToString() + " ml" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Yw"]))
            //{
            this.litYw.Text = result.YW.HasValue ? Math.Round(result.YW.Value, 1).ToString() + "cm" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Tw"]))
            //{
            this.litTw.Text = result.TW.HasValue ? Math.Round(result.TW.Value, 1).ToString() + "cm" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Ssy"]) && !Convert.IsDBNull(reader2["Szy"]))
            //{
            this.litXy.Text = result.SSY.HasValue ? Math.Round(result.SSY.Value, 1).ToString() : "" + "/" + result.SZY as string;
            //}
            //if (!Convert.IsDBNull(reader2["lsl"]) && !Convert.IsDBNull(reader2["rsl"]))
            //{
            //this.litSl.Text = "左 " + Convert.ToDouble(reader2["lsl"]).ToString("N1") + " / 右 " + Convert.ToDouble(reader2["rsl"]).ToString("N1");
            string lsl = result.LSL.HasValue ? Math.Round(result.LSL.Value, 1).ToString() : "";
            string rsl = result.RSL.HasValue ? Math.Round(result.RSL.Value, 1).ToString() : "";
            this.litSl.Text = "左 " + lsl + " / 右 " + rsl;
            //}
            //this.litQg.Text = "左 " + reader2["lqg"] as string + " / 右 " + reader2["rqg"] as string;
            this.litQg.Text = "左 " + result.LQG + " / 右 " + result.RQG as string;
            this.litRs.Text = result.RS as string;
            this.litSj.Text = result.BS as string;
            this.litSy.Text = result.SSYPJ as string;
            this.litJmy.Text = result.JMY as string;
            //this.litQc.Text = reader2["Qcpj"] as string;
            this.litQc.Text = result.QCQFY.HasValue ? result.QCQFY.Value.ToString() : "";
            this.litYzb.Text = result.YZB as string;
            this.litTl.Text = "左 " + result.T1 + " / 右 " + result.RTL as string;
            this.litEb.Text = result.EB as string;
            this.litBb.Text = result.BB as string;
            this.litTb.Text = result.TB as string;
            this.litJb.Text = result.JB as string;
            this.litBtt.Text = result.BTT as string;

            this.litXk.Text = result.XK as string;

            this.litJz.Text = result.JZ as string;
            this.litSz.Text = result.SZ as string;
            this.litPf.Text = result.PF as string;
            this.litLbj.Text = result.LBJ as string;

            this.litWszq.Text = result.WSZQ as string;

            this.litXz.Text = result.XZ as string;
            this.litFei.Text = result.FEI as string;
            this.litGan.Text = result.GP as string;
            this.litPei.Text = result.PEI as string;
            //if (!Convert.IsDBNull(reader2["Mb"]))
            //{
            this.litMb.Text = result.MB.HasValue ? Math.Round(result.MB.Value, 1).ToString() + "  次/分钟" : "";
            //}
            //if (!Convert.IsDBNull(reader2["Xhdb"]))
            //{
            this.litXhdb.Text = "血红蛋白：" + (result.XHDB.HasValue ? result.XHDB.Value.ToString() + "  g/L" : "");
            //}
            this.litGg.Text = result.GG;
            this.litJhjs.Text = result.JHJS;
            this.litHcl.Text = result.FHCL;
            this.litXx.Text = result.BLOOD;
            if (result.XB == "男")
            {
                this.litQcq.Text = "男生：若出现遗精，首次遗精年龄 " + result.QCQFY + " 岁";
            }
            else
            {
                this.litQcq.Text = "女生：若出现月经，初潮年龄 " + result.QCQFY + " 岁";
            }

            //litSgpj.Text = result.SGDJD;
            //litTzpj.Text = result.TZDJD;
            //litAge.Text = (result.NL.HasValue ? result.NL.Value.ToString() : "未知");
            //litFypj.Text = result.FYPJ;
            //litPz.Text = result.PZ;
            //litJzx.Text = result.JZX;
            //litGbzam.Text = result.GBZAM.HasValue ? Math.Round(result.GBZAM.Value, 2).ToString() : "";//谷丙转氨酶
            //litPx.Text = result.PXPJ;
            //litBmkt.Text = result.BMKT;
            //litXwpj.Text = result.XWDJD;
            //litFhlpj.Text = result.FHLDJD;
            //litYypj.Text = result.YYPJ;
            //litDhs.Text = result.DHSA.HasValue ? Math.Round(result.DHSA.Value).ToString() : "";
            //litBmky.Text = result.BMKY;
            litHcl.Text = result.FHCL;

            string vaccin = string.Empty;
            if (!string.IsNullOrEmpty(result.YMA))
            {
                vaccin += "卡介苗：" + result.YMA+"　　";
            }
            if (!string.IsNullOrEmpty(result.YMB))
            {
                vaccin += "乙型肝炎疫苗:" + result.YMB + "　　";
            }
            if (!string.IsNullOrEmpty(result.YMC))
            {
                vaccin += "麻疹疫苗：" + result.YMC + "　　";
            }
            if (!string.IsNullOrEmpty(result.YMD))
            {
                vaccin += "脊髓灰质炎疫苗：" + result.YMD + "　　";
            }
            if (!string.IsNullOrEmpty(result.YME))
            {
                vaccin += "百白破疫苗：" + result.YME + "　　";
            }
            var selfvaccin= manager.GetSelfVaccin(tjnd, studentid);
            if (selfvaccin.Rows.Count > 0)
            {
                if (!string.IsNullOrEmpty(selfvaccin.Rows[0]["V1Name"] as string))
                    vaccin += selfvaccin.Rows[0]["V1Name"] + ":" + selfvaccin.Rows[0]["V1"] + "　　";
                if (!string.IsNullOrEmpty(selfvaccin.Rows[0]["V2Name"] as string))
                    vaccin += selfvaccin.Rows[0]["V2Name"] + ":" + selfvaccin.Rows[0]["V2"] + "　　";
                if (!string.IsNullOrEmpty(selfvaccin.Rows[0]["V3Name"] as string))
                    vaccin += selfvaccin.Rows[0]["V3Name"] + ":" + selfvaccin.Rows[0]["V3"] + "　　";
                if (!string.IsNullOrEmpty(selfvaccin.Rows[0]["V4Name"] as string))
                    vaccin += selfvaccin.Rows[0]["V4Name"] + ":" + selfvaccin.Rows[0]["V4"] + "　　";
                if (!string.IsNullOrEmpty(selfvaccin.Rows[0]["V5Name"] as string))
                    vaccin += selfvaccin.Rows[0]["V5Name"] + ":" + selfvaccin.Rows[0]["V5"];
            }
            litYjz.Text = vaccin;
        }
    }
}